;define function reactor for publish command start and end
(vlr-command-reactor 
	nil '((:vlr-commandWillStart . start-cmd)))
(vlr-command-reactor 
	nil '((:vlr-commandEnded . end-cmd)))

;publish command starts - set bulletin board variable to 1
(defun start-cmd (calling-reactor start-cmdInfo / 
		     cmd-start)
(setq cmd-start (nth 0 start-cmdInfo))
(cond
  ((= cmd-start "PUBLISH") (vl-bb-set 'bb-Publish "1"))
);cond
(princ)
);defun

;publish command ends - call fc:cmd-Publish function
(defun end-cmd (calling-reactor end-cmdInfo / 
		   cmd-end)
(setq cmd-end (nth 0 end-cmdInfo))
(cond
  ((= cmd-end "PUBLISH") (fc:cmd-Publish))
);cond
 (princ)
);defun


;evaluate publish reactor on drawing open
;if value not equal to (1) one - load menu routines
;else quick open - none loaded
(if (/= (vl-bb-ref 'bb-Publish) "1")
  (PROGN
    (PRINC "\nUpon opening the drawing we found the PUBLISH command is not active. ")
    (PRINC)
  )
  (progn
    (IF c:setdef NIL (LOAD "SETDEF" "\nFile SETDEF.LSP not loaded! "))
    (IF c:setdef
      (c:setdef)
      (PROGN
        (PRINC "\nCould not execute SETDEF in reaction to opening a drawing with the PUBLISH command active. ")
        (PRINC)
      )
    )
  )
)

;set bulletin board for standard file open
;when publish is called bulletin board is
;updated to run reactor on all files, reset on end
(defun fc:cmd-Publish ( / )
  (vl-bb-set 'bb-Publish "0")
)
;;;Autodesk Forums: Discussion Groups: Visual Lisp, AutoLISP and General Customization:
;;;post by rmiller1973 on 04-13-2011 @ 12:00PM
;;;
;;;You can try the code above:
;;;
;;;I have it added to the menu load rountine (MNL) so the reactor is loaded and ready for evaluation in every file.
;;;I believe the Publish command is a single event so it requires a method to pass that information to the published set.
;;;So that is why the bulletin board is being used to expose that the publish command is active for each drawing in the set.
;;;
;;;Our environment is extremely customized so our Publish reactor was set to reduce the menu load and custom routines
;;;down to a minimum - to mimic opening the default AutoCAD profile. You can remove that aspect out of the reactor but
;;;I figured I would explain how it was currently setup.
;;;
;;;Anyway, a standard open would result in the bulletin board value for the Publish command to be set to "0". If the Publish
;;;command is called the bulletin board value is set to "1" and it will remain that way until the command ends. At which time
;;;the last section will allow the bulletin board to reset and switch back to a normal load.
;;;
;;;Reactor might not work correctly with a Publish called from certain elements of the Project Navigator or Sheet Set Manager
;;; - if you open the Publish dialog box it should work. I will see if I can isolate how the Project Navigator or Sheet Set
;;;Manager is calling the command if you need it.
;;;
;;;Rob

